<?php

define("APP", "Lidas");
ini_set('display_errors', 1);
error_reporting(-1);

class LidasException extends Exception {

    public static function capture($number, $message, $file, $line) {
        if (error_reporting() != 0) {
            $ex = new LidasException($message, $number, NULL);
            $ex->file = $file;
            $ex->line = $line;
            throw $ex;
        }
    }

    public function __toString() {
        $msg = get_class($this) . ': ' . $this->code . ' ' . $this->message . PHP_EOL;
        $msg .= '    at ' . $this->getFile() . ':' . $this->getLine();
        try {
            foreach ($this->getTrace() as $trace) {
                $tr = array_merge(array('file' => '?file?', 'line' => '?line?', 'type' => '?', 'function' => '?fn?'), $trace);
                if (isset($tr['class'])) {
                    $msg .= PHP_EOL . '    at ' . $tr['class'] . $tr['type'] . $tr['function'] . ' (' . $tr['file'] . ':' . $tr['line'] . ')';
                } else {
                    $msg .= PHP_EOL . '    at ' . $tr['file'] . ':' . $tr['line'];
                }
            }
        } catch (Exception $ex) {
            // $msg .= (string) $ex;
        }
        return $msg;
    }

}

set_error_handler(array('LidasException', 'capture'), E_ALL);

spl_autoload_register(function ($class) {
            $filename = join(DIRECTORY_SEPARATOR, array_reverse(explode('_', strtolower($class)))) . '.php';
            if (file_exists($filename))
                include_once $filename;
        });

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

abstract class element {

    public abstract function Add(element $e);

    public abstract function HTML();
}

class html extends element {

    public function HTML(element $inner) {
        return "<html>" . $inner->HTML() . "</html>";
    }

    public function Add(element $e) {
        
    }

}

?>
